import {createRouter, createWebHashHistory,createWebHistory} from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SearchView from '@/views/SearchView.vue'


const routes = [
  {path: '/home', component: HomeView,name:'aa'},
  //{path: '/search', component: SearchView}
  // {path: '/search/:word', component: SearchView}
  //?可选
  {path: '/search/:word?', component: SearchView},
  //重定向
  {path:'/',redirect:'/home'},
  // //404页面
  // { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
  {path: '/home', component: ()=>import('@/views/HomeView.vue')},
  {name: 'search', path: '/search/:words?', component: ()=>import('@/views/SearchView.vue')},

]

const router = createRouter({
  // history: createWebHashHistory(),
  history: createWebHistory(),
  routes
})

export default router                